#include <Windows.h>
#include <MSCorEE.h>
#include <stdio.h>

void main(int argc, WCHAR **argv) {
   // Load the CLR
   ICLRRuntimeHost *pClrHost;
   HRESULT hr = CorBindToRuntimeEx(
      NULL,                 // desired CLR version (NULL=latest)
      NULL,                 // desired GC flavor (NULL=workstation)
      0,                    // desired startup flags
      CLSID_CLRRuntimeHost, // CLSID of CLR
      IID_ICLRRuntimeHost,  // IID of ICLRRuntimeHost
      (PVOID*) &pClrHost);  // returned COM interface

   // (This is where you would set Host managers)
   // (This is where you could get CLR managers)

   // Initialize and start the CLR
   pClrHost->Start();

   // Load an assembly and call a static method that 
   // takes a String and returns an Int32
   DWORD retVal;
   hr = pClrHost->ExecuteInDefaultAppDomain(
      L"..\\..\\..\\D-Host_MgdAssem\\bin\\Debug\\MgdAssem.dll", 
      L"Wintellect.SomeType", L"SomeMethod", L"Jeff", &retVal);

   // Show the result returned from managed code
   wprintf(L"Managed code returned %d", retVal);

   // Terminate this process (destroying the CLR loaded in it)
}
